package com.zfj.TreeSet;

import java.util.Iterator;
import java.util.TreeSet;

/**
 * @author zfj
 * @date 2022/3/7 -15:45
 * TreeSet的使用
 * 存储结构：红黑树
 */
public class Demo1 {
	public static void main(String[] args) {
		TreeSet<String> treeSet=new TreeSet<>();
		treeSet.add("xyz");
		treeSet.add("abc");
		treeSet.add("hlm");
		System.out.println(treeSet.toString());
		//删除
		treeSet.remove("xyz");
		//遍历
		for (String s : treeSet) {
			System.out.println(s);
		}
		System.out.println("=======================");
		Iterator<String> iterator = treeSet.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
	}
}
